﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;
using Webchatting.Common;
using Webchatting.Dal;

public partial class server_EditFriendRemarkName : System.Web.UI.Page
{
    public static ArrayList arrFRUIds = new ArrayList();
    public static ArrayList arrFRURemarkNames = new ArrayList();
    public static ArrayList arrFRUNickNames = new ArrayList();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnGetFriendRemark_Click(object sender, EventArgs e)
    {
        OperationFriends OFriends = new OperationFriends();
        FormsIdentity id = (FormsIdentity)User.Identity;
        string getFriends = OFriends.GetFriendRemark(id.Ticket.UserData.Split('@')[0], arrFRUIds, arrFRURemarkNames, arrFRUNickNames);

        ltlResult.Text = "<b>搜索结果：</b><br/>" + getFriends;
        ltlText.Text = "<b>请选择要修改备注名称的好友ID：</b>";
        ddlAddFriend.Visible = true;
        btnGetFriendRemark.Visible = true;
        btnEditFriend0.Visible = true;
        ltlNickName0.Visible = true;
        TextBox1.Visible = true;

        while (ddlAddFriend.Items.Count > 0)
        {
            ddlAddFriend.Items.RemoveAt(0);
        }

        for (int i = 0; i < arrFRUIds.Count; i++)
        {
            ddlAddFriend.Items.Add(new ListItem((string)arrFRUIds[i], (string)arrFRUIds[i]));
        }

    }
    protected void btnEditFriend_Click(object sender, EventArgs e)
    {
        OperationFriends OFriend2 = new OperationFriends();

        int selected = ddlAddFriend.SelectedIndex;
        FormsIdentity id2 = (FormsIdentity)User.Identity;

        try
        {
           
            OFriend2.EditFriendRemark(id2.Ticket.UserData.Split('@')[0], arrFRUIds[selected].ToString(), TextBox1.Text.Trim());


            Response.Write("<script>alert('修改好友备注名称成功!');window.parent.location.href='RUIndex.aspx';</script>");
           
        }
        catch
        {
            Javascript.GoHistory(-1, "修改失败！", Page);
        }
    }
}
